<template>
  <div>
    <el-button type="text" @click="dialogVisible = true">点击打开 Dialog</el-button>
<!--  -->
    <el-dialog
      title="添加一个新用户"
      :visible.sync="dialogVisible"
      width="30%"
      @close="hClose"
      @open="hOpen"
      :before-close="handleClose"
      >

      <el-form>
        <el-form-item label="用户名">
          <el-input />
        </el-form-item>
      </el-form>

      <!-- 具名插槽 -->
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false">确 定</el-button>
      </span>
      
    </el-dialog>

  </div>
</template>


<script>
  export default {
    data() {
      return {
        // 是否打开弹框
        dialogVisible: false
      };
    },
    methods: {
      hOpen() {
        console.log('弹框打开')
      },
      hClose() {
        console.log('弹框关闭')
      },
      handleClose(done) {
        this.$confirm('确认关闭？')
          .then(abc => {
            console.log(abc)
            done();
          })
          .catch(_ => {
            console.log(_)
          });
      }
    }
  };
</script>